import Mock from 'mockjs'
/***
 * 登录 参数  { userName: '', passWord: ''}
 * 返回 { userName: '', passWord: ''}
 * */
Mock.mock(/\/mock\/login/, 'post', ({ body }) => {
    let obj = JSON.parse(body)
    let tokenObj = { token: '' }
    if (obj.userName == 'admin') {
        tokenObj.token = 'admin'
    } else {
        tokenObj.token = 'vip'
    }
    return {
        code: '200',
        message: 'success',
        datas: { ...obj, ...tokenObj }
    }
})

/**
 * 权限 参数 {token:''}
 * **/
let adminData = [{ name: '订单管理', children: [{ name: '订单列表' }, { name: '订单汇总' }, { name: '订单合同' }, { name: '订单详情' }] }, { name: '产品管理', children: [{ name: '产品列表' }, { name: '产品分类' }, { name: '产品处理' }] }, { name: '广告管理', children: [{ name: '广告列表' }] }, { name: '系统管理', children: [{ name: '角色管理' }, { name: '系统分类' }] }]
let vipData = [{ name: '订单管理', children: [{ name: '订单列表' }] }, { name: '产品管理', children: [{ name: '产品列表' }, { name: '产品处理' }] }]
let datas = []
Mock.mock(/\/mock\/promision/, 'post', ({ body }) => {
    let token = JSON.parse(body).token
    if (token == 'admin') {
        datas = adminData
    } else {
        datas = vipData
    }
    return {
        code: '200',
        message: 'success',
        datas: datas || []
    }
})